using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data.SqlClient;

namespace DAO
{
    public class InventoryDAO
    {
        // lay thong tin hang` hoa (man` hinh` 1)
        public Inventory GetInvtPurchaseInfo(int maHang)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "select Description, PurchaseUnit, PurchasePrice, ConvertUnit from DMS_Inventory where InvtID = " + maHang;
            Inventory inventory = new Inventory();

            SqlDataReader reader = provider.ExecuteReader(command);
            reader.Read();
            inventory.InventId = maHang;
            inventory.Desc = reader.GetString(0);
            inventory.PurchaseUnit = reader.GetInt32(1);
            inventory.PurcharsePrice = reader.GetInt32(2);
            inventory.ConvertUnit = reader.GetInt32(3);
            
            reader.Close();
            provider.Close();

            return inventory;
        }
    }
}
